import java.util.Iterator;
import java.util.Vector;

import common.MyNode;
import common.Property;
import common.SkillManInstance;
import common.SkillManSchema;
import common.SkillManSearch;
import common.SkillManTaxonomy;


public class Try {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception
	{
		SkillManSchema schema=new SkillManSchema();
		schema.setCWD(Property.skillMgmHome);
		schema.load();
		schema.addSkill("Programming", "Python", "Knowledge of python programming language.");
		
		System.out.println();
		System.out.println();
		SkillManInstance inst = new SkillManInstance(schema, "adolfo.owl");
		inst.setCWD(Property.instances);
		inst.loadDefault(Property.skillMgmHome+"default_instance.owl");
		inst.setPropertyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name" ,"Adolfo Hitler");
		inst.addSkill("Java", 5);
		inst.addSkill("Java", 2);
		inst.addSkill("C_Socket", 4);
		System.out.println("Name: "+inst.getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
		System.out.println("Java skill level: "+inst.getSkillLevel("Java"));
		
		System.out.println();
		System.out.println();
		SkillManInstance base = new SkillManInstance(schema, "slabodoschi.owl");
		base.setCWD(Property.instances);
		base.loadDefault(Property.skillMgmHome+"default_instance.owl");
		base.setPropertyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name" ,"Jocopoco Majoco");
		base.addSkill("Java", 5);
		base.addSkill("C_Socket", 5);
		base.addSkill("Java_SWT", 3);		
		System.out.println("Name: "+base.getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
		System.out.println("Java skill level: "+base.getSkillLevel("Java"));
		
		System.out.println();
		System.out.println("Qua finiscono le istanze");
		System.out.println();
		float perc=inst.compareTo(base);
		System.out.println("Le istanze sono uguali al "+perc+"%.");
		
		System.out.println();
		System.out.println();
		SkillManSearch search=new SkillManSearch(schema, base, Property.instances );
		
		search.loadFiles();
		search.loadOnts();
		search.compareToAll();
		
		System.out.println();
		System.out.println();
		search.sortResults();
		System.out.println();
		System.out.println();
		System.out.println("Risultati");
		System.out.println(search.sortResultsList());
		
		////////
		
		Vector<common.MySkill> skills=inst.getSkills();
		System.out.println("\n--- Ecco tutte le skill di "+inst.getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
		for( int j=0; j<skills.size(); j++ )
		{
			System.out.println("Nome skill: "+skills.get(j).skill);
			System.out.println("Livello: "+skills.get(j).lvl+"\n");
		}
		
		System.out.println();
		SkillManTaxonomy tax=schema.getTaxonomy();
		Vector<MyNode> vtax=tax.getTaxonomy();
		for( int i=0; i<vtax.size(); i++ )
		{
			String skill=vtax.get(i).child.getLocalName();
			int n=search.getNumBySkill(skill);
			System.out.println("\t"+skill+" ("+n+")");
		}
		
		System.out.println();
		System.out.println();
		System.out.println("Guga merda");
		System.out.println();
		System.out.println();
		
		Vector<SkillManInstance> javaComp=search.getInstancesBySkill("Java");
		System.out.println("Persone competenti in Java: ");
		for( int i=0; i<javaComp.size(); i++ )
		{
			System.out.println("- "+javaComp.get(i).getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
		}
		
	}

}
